<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head>


<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="ProgId" content="Word.Document">
<meta name="Generator" content="Microsoft Word 9">
<meta name="Originator" content="Microsoft Word 9">
<link rel="File-List" href="http://uva.onlinejudge.org/external/100/a_files/filelist.xml">
<link rel="Edit-Time-Data" href="http://uva.onlinejudge.org/external/100/a_files/editdata.mso">
<link rel="OLE-Object-Data" href="http://uva.onlinejudge.org/external/100/a_files/oledata.mso">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>Problem D - The Tourist Guide</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>RAC</o:Author>
  <o:LastAuthor>Administrator</o:LastAuthor>
  <o:Revision>5</o:Revision>
  <o:TotalTime>2</o:TotalTime>
  <o:LastPrinted>1999-05-07T21:27:00Z</o:LastPrinted>
  <o:Created>2001-01-10T15:36:00Z</o:Created>
  <o:LastSaved>2001-01-13T15:44:00Z</o:LastSaved>
  <o:Pages>2</o:Pages>
  <o:Words>341</o:Words>
  <o:Characters>1945</o:Characters>
  <o:Company>CSE, BUET</o:Company>
  <o:Lines>16</o:Lines>
  <o:Paragraphs>3</o:Paragraphs>
  <o:CharactersWithSpaces>2388</o:CharactersWithSpaces>
  <o:Version>9.2720</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>0</w:DisplayVerticalDrawingGridEvery>
  <w:UseMarginsForDrawingGridOrigin/>
  <w:Compatibility>
   <w:FootnoteLayoutLikeWW8/>
   <w:ShapeLayoutLikeWW8/>
   <w:AlignTablesRowByRow/>
   <w:ForgetLastTabAlignment/>
   <w:LayoutRawTableWidth/>
   <w:LayoutTableRowsApart/>
  </w:Compatibility>
 </w:WordDocument>
</xml><![endif]-->
<style>
<!--
 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	color:black;}
strong
	{mso-bidi-font-weight:normal;}
em
	{mso-bidi-font-style:normal;}
p.Preformatted, li.Preformatted, div.Preformatted
	{mso-style-name:Preformatted;
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:none;
	tab-stops:0in 47.95pt 95.9pt 143.85pt 191.8pt 239.75pt 287.7pt 335.65pt 383.6pt 431.55pt 479.5pt;
	layout-grid-mode:char;
	font-size:10.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";}
p.DefinitionTerm, li.DefinitionTerm, div.DefinitionTerm
	{mso-style-name:"Definition Term";
	mso-style-next:"Definition List";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	layout-grid-mode:char;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
p.DefinitionList, li.DefinitionList, div.DefinitionList
	{mso-style-name:"Definition List";
	mso-style-next:"Definition Term";
	margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:.25in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	layout-grid-mode:char;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
p.H2, li.H2, div.H2
	{mso-style-name:H2;
	mso-style-next:Normal;
	margin-top:5.0pt;
	margin-right:0in;
	margin-bottom:5.0pt;
	margin-left:0in;
	mso-pagination:widow-orphan;
	page-break-after:avoid;
	mso-outline-level:3;
	layout-grid-mode:char;
	font-size:18.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	font-weight:bold;
	mso-bidi-font-weight:normal;}
p.Address, li.Address, div.Address
	{mso-style-name:Address;
	mso-style-next:Normal;
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	layout-grid-mode:char;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	font-style:italic;
	mso-bidi-font-style:normal;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1029"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
</head><body style="" lang="EN-US">

<div class="Section1">

<p class="MsoNormal" style="text-align: center;" align="center"><b style=""><font size="5">Problem D</font></b></p>

<p class="MsoNormal" style="text-align: center;" align="center"><b style=""><font size="6">The Tourist Guide</font></b></p>


<p class="MsoNormal" style="text-align: center;" align="center"><b style="">Input: </b><span style="">standard input<o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: center;" align="center"><b style="">Output: </b>standard output</p>

<p class="MsoNormal" style="text-align: justify;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></p>

<p class="MsoNormal" style="text-align: justify;">Mr. G. works as a tourist guide.
His current assignment is to take some tourists from one city to another. Some
two-way roads connect the cities. For each pair of neighboring cities there is
a bus service that runs only between those two cities and uses the road that
directly connects them. Each bus service has a limit on the maximum number of
passengers it can carry. Mr. G. has a map showing the cities and the roads
connecting them. He also has the information regarding each bus service. He
understands that it may not always be possible for him to take all the tourists
to the destination city in a single trip. For example, consider the following
road map of 7 cities. The edges connecting the cities represent the roads and
the number written on each edge indicates the passenger limit of the bus
service that runs on that road. </p>

<p class="MsoNormal" style="text-align: justify;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="acm-10099_files/p10099.gif" height="287" width="344">

<p class="MsoNormal" style="text-align: justify; text-indent: 0.5in;">Now, if he wants
to take 99 tourists from city 1 to city 7, he will require at least 5 trips, since he has to ride the bus with each group, and
the route he should take is : 1 - 2 - 4 - 7. </p>

<p class="MsoNormal" style="text-align: justify; text-indent: 0.5in;">But, Mr. G.
finds it difficult to find the best route all by himself so that he may be able
to take all the tourists to the destination city in minimum number of trips.
So, he seeks your help.</p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 14pt;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></b></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><font size="5">Input</font></b></p>


<p class="MsoNormal" style="text-align: justify;">The input will contain one or
more test cases. The first line of each test case will contain two integers: <i style="">N</i> (N&lt;= 100) and <i style="">R</i> representing respectively the number of cities and the number of
road segments. Then <i style="">R</i> lines will
follow each containing three integers: <i style="">C</i><sub><span style="color: windowtext;">1</span></sub>, <i style="">C</i><i style=""><sub><span style="color: windowtext;">2</span></sub></i>
and <i style="">P</i>. <i style="">C</i><sub><span style="color: windowtext;">1</span></sub> and <i style="">C</i><i style=""><sub><span style="color: windowtext;">2</span></sub></i> are the city numbers and <i style="">P</i> (P&gt; 1) is the limit on the maximum
number of passengers to be carried by the bus service between the two cities.
City numbers are positive integers ranging from 1 to <i style="">N</i>. The (<i style="">R</i> + 1)-th line
will contain three integers: <i style="">S</i>, <i style="">D</i> and <i style="">T</i> representing respectively the starting city, the destination city
and the number of tourists to be guided. </p>

<p class="MsoNormal" style="text-align: justify; text-indent: 0.5in;">The input will
end with two zeroes for <i style="">N</i> and <i style="">R</i>.</p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 14pt;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></b></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><font size="5">Output</font></b></p>


<p class="MsoNormal" style="text-align: justify;">For each test case in the input
first output the scenario number. Then output the minimum number of trips
required for this case on a separate line. Print a blank line after the output of
each test case.<b style=""><span style="font-size: 14pt;"><o:p></o:p></span></b></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 14pt;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></b></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><font size="5">Sample Input</font></b></p>
<font face="Courier" size="3">

7 10<br>

1 2 30<br>

1 3 15<br>

1 4 10<br>

2 4 25<br>

2 5 60<br>

3 4 40<br>

3 6 20<br>

4 7 35<br>

5 7 20<br>

6 7 30<br>

1 7 99<br>

0 0<br>

<br>
</font>
<p class="MsoNormal" style="text-align: justify;"><b style=""><font size="5">Sample Output</font></b></p>

<font face="Courier" size="3">

Scenario #1<br>

Minimum Number of Trips = 5<br>
<br>
</font>
</div>
<font face="Times New Roman" size="3">
</font><hr>
<font face="Times New Roman" size="3">Rezaul Alam Chowdhury
</font></body></html>